<!-- src\components\GoodItem.vue -->
<template>
    <div class="good-item" @click="goToDetail(id)">
        <img :src="cover" alt="">
        <div class="good-desc">
            <div class="title">{{ name }}</div>
            <div class="price">￥ {{ price }}</div>
        </div>
    </div>
</template>
<script>
export default{
    props: {
        id: {
            type: Number,
            default: ''
        },
        cover: {
            type: String,
            default: ''
        },
        name: {
            type: String,
            default: ''
        },
        price: {
            type: Number,
            default: ''
        },
        goToDetail: {
            type: Function,
            default: () => {}
        }
    },
    setup(props, ctx) {
        const goToDetail = (id) => {
            ctx.emit('goToDetail', id)
        }
        return {
            goToDetail
        }
    }
}
</script>

<style lang="less" scoped>
@import "../theme/custom.less";
.good-item{
    box-sizing: border-box;
    width: 50%;
    border-bottom: 1PX solid #e9e9e9;
    padding: 10px 10px;
    img{
        display: block;
        width: 120px;
        margin: 0 auto;
    }
    .good-desc{
        text-align: center;
        font-size: 14px;
        padding: 10px 0;
        .title{
            color: #222333;
        }
        .price {
            color: @primary;
        }
    }
    &:nth-child(2n +1){
        border-right: 1PX solid #e9e9e9;
    }
}
</style>